package com.exam.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.exam.entity.ExamManage;
import com.exam.entity.tail;
import com.exam.mapper.ExamManageMapper;
import com.exam.service.ExamManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExamManageServiceImpl implements ExamManageService {
    @Autowired
    private ExamManageMapper examManageMapper;


    @Override
    public List<ExamManage> findAll() {
        return examManageMapper.findAll();
    }

    @Override
    public IPage<ExamManage> findAll(Page<ExamManage> page) {
        return examManageMapper.findAll(page);
    }
    @Override
    public IPage<ExamManage> findAll(Page<ExamManage> page,String date,String bz) {
        if(bz.equals("ing")){
            return examManageMapper.findAlling(page,date);

        }else if(bz.equals("end")){
            return examManageMapper.findAllend(page,date);

        }else if(bz.equals("nostart")){
            return examManageMapper.findAllnostart(page,date);

        }
        return examManageMapper.findAll(page);
    }
    @Override
    public tail findAlltail(String date) {
        String tail=examManageMapper.findAlltail();
        String endtail=examManageMapper.findAllendtail(date);
        String ingtail=examManageMapper.findAllingtail(date);
        String notail=examManageMapper.findAllnostarttail(date);
        tail tail1 =new tail();
        tail1.setTail(tail);
        tail1.setEndtail(endtail);
        tail1.setIngtail(ingtail);
        tail1.setNotail(notail);

        return tail1;
    }
    @Override
    public ExamManage findById(Integer examCode) {
        return examManageMapper.findById(examCode);
    }

    @Override
    public int delete(Integer examCode) {
        return examManageMapper.delete(examCode);
    }

    @Override
    public int update(ExamManage exammanage) {
        return examManageMapper.update(exammanage);
    }

    @Override
    public int add(ExamManage exammanage) {
        return examManageMapper.add(exammanage);
    }

    @Override
    public ExamManage findOnlyPaperId() {
        return examManageMapper.findOnlyPaperId();
    }
}
